//
//  BaseModel.m
//  礼物说
//
//  Created by dllo on 16/4/21.
//  Copyright © 2016年 sunzhichao. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel

- (instancetype) initWithDic:(NSDictionary *)dic {
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

+ (instancetype) modelWithDic:(NSDictionary *)dic {
    return [[[[self class] alloc] initWithDic:dic] autorelease];
}

+ (NSMutableArray *)modelHandleWithArray:(NSArray *)array {
    /** 创建Model*/
    NSMutableArray *arrModel = [NSMutableArray array];
    /** 遍历字典*/
    for (NSDictionary *dic in array) {
        /** 把字典转换成model*/
        BaseModel *model = [[self class] modelWithDic:dic];
        /** 把model添加到model 数组中*/
        [arrModel addObject:model];
    }
    return arrModel;
}

- (id)valueForUndefinedKey:(NSString *)key {
    return nil;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

@end
